package com.dwxt.community.admin.service;

import com.dwxt.common.base.BaseResult;
import com.dwxt.common.base.StatusCode;
import com.dwxt.community.dao.InformationImgMapper;
import com.dwxt.community.entity.InformationImg;
import com.dwxt.community.entity.InformationImgExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class InformationImgService {

    @Autowired
    private InformationImgMapper informationImgMapper;

    //查询
    public BaseResult selectPageList() {
       return BaseResult.ok(informationImgMapper.selectByExample(new InformationImgExample()));
    }

    /**
     * 新增或更新
     */
    public BaseResult insertOrUpdate(InformationImg informationImg){
        //新增
        if (informationImg.getId()==null){
            informationImgMapper.insertSelective(informationImg);
            return BaseResult.ok();
        }else {
            //更新
            informationImgMapper.updateByPrimaryKeySelective(informationImg);
            return BaseResult.ok();
        }
    }

    /**
     * 删除
     */
    public BaseResult deleteById(Integer id){
        informationImgMapper.deleteByPrimaryKey(id);
        return BaseResult.ok();
    }

}
